﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ShowRooms.aspx.cs" Inherits="ZLDC.Estate.TM.ShowRooms" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <base target="_self" />
    <title>房号列表</title>
    <link href="../css/main.css" rel="stylesheet" type="text/css" />
    <link href="../js/jquery/style/jquery.hiAlerts.css" rel="stylesheet" type="text/css" />

    <script src="../js/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>

    <script src="../js/jquery/jquery.hiAlerts-min.js" type="text/javascript"></script>

    <script src="../js/LexunJS.js" type="text/javascript"></script>

    <style type="text/css">
        .text
        {
            color: #0066FF;
            background: #F7F7F7;
            border-color: black black #999999;
            border-style: solid;
            border-top-width: 0px;
            border-right-width: 0px;
            border-bottom-width: 1px;
            border-left-width: 0px;
            font-size: 12px;
        }
        ul
        {
            padding: 0;
            width: 520px; /*设置表格宽 */
            height: auto; /*设置表格高*/
            margin: 0px;
        }
        li
        {
            /*设置单元格边框*/
            list-style: none; /*清除项目列表前的标记*/
            float: left; /*设置单元格浮动，用于水平排列*/
            display: block; /*设置单元格为块级元素于用语控制大小等*/
            width: 100px; /*设置单元格宽*/
            height: 38px; /*设置单元格高*/
            text-align: center; /*设置单元格内文本对齐方式*/
            margin: 1px;
        }
    </style>

    <script type="text/javascript">
        ///取回
        function getVal(id, name,floor) {

            if (id.length > 0 && name.length > 0) {
                window.returnValue = name + "," + id + "," + floor;
                window.close();
            }
            else {
                window.returnValue = "";
            }
        }

        $(document).ready(function() {
            ShowRoomNoList();
        });
        
        /*
        功能: 将返回的json数据进行排版
        json: json数据
        */
        function listCallBack(response) {
            var json = eval("(" + response + ")");
            var record = json.record;

            if (record == null || record.length == 0) {
                $("#divList1").html("<font color='red'>&nbsp;系统内暂无您查询的信息!</font>");
                return;
            }

            var arr = [];
            arr.push("<table id='table1' width='100%' border='0' cellpadding='0' cellspacing='1' bgcolor='#a8c7ce'>");
            arr.push("<tr>");
            arr.push("<td height='25' width='60px' bgcolor='d3eaef' class='STYLE6'>");
            arr.push("楼层");
            arr.push("</td>");
            arr.push("<td height='25' width='60px' bgcolor='d3eaef' class='STYLE6'>");
            arr.push("用途");
            arr.push("</td>");
            arr.push("<td height='25' bgcolor='d3eaef' class='STYLE6'>");
            arr.push("房号");
            arr.push("</td>");
            arr.push("</tr>");

            var recordLength = record.length;
            var floor1 = -9999;
            var floor2 = 0;
            for (var i = 0; i < recordLength; i++) {
                floor2 = record[i].floor;

                if (floor1 != floor2) {
                    if (floor1 != -9999) {
                        arr.push("</ul>");
                        arr.push("</td>");
                        arr.push("</tr>");
                    }
                    floor1 = floor2
                    if (i % 2 == 0)
                        arr.push("<tr id='tr_" + record[i].id + "' bgcolor='#FFFFFF'>");
                    else
                        arr.push("<tr id='tr_" + record[i].id + "' bgcolor='#EEEDED'>");

                    arr.push("<td height='20' class='STYLE6'>");
                    arr.push(floor2);
                    arr.push("</td>");
                    arr.push("<td height='20' class='STYLE6'>");
                    arr.push(LexunJS.GetUsageNameById(record[i].usage));
                    arr.push("</td>");
                    arr.push("<td height='20' class='STYLE6'>");
                    arr.push("<ul>");
                }

                if (record[i].bstatus == 1) {
                    arr.push("<li  style = 'background:#FF99FF' >");
                }
                else if (record[i].bstatus == 2) {
                    arr.push("<li style = 'background:Yellow' >");
                }
                else if (record[i].bstatus == 3) {
                    arr.push("<li style = 'background:#66CCFF' >");
                }
                else {
                    arr.push("<li>");
                }
                arr.push("<div title='" + record[i].name + "'>" + record[i].name.substring(0, 8) + "</div>");
//                if (record[i].bstatus != 3) {
//                    arr.push("<a  href=\"javascript:getVal('" + record[i].id + "','" + record[i].name + "','"+record[i].floor+"')\"  style='color:blue'  href='' >取回</a>");
//                }
               if (record[i].isvalid == 1)
                    arr.push("<div style='color:red;'>未审核</div>");
                else {

                    if (record[i].bstatus != 3) {
                        arr.push("<a  href=\"javascript:getVal('" + record[i].id + "','" + record[i].name + "','" + record[i].floor + "')\"  style='color:blue'  href='' >取回</a>");
                    }

                }

                arr.push("</li>");

            }
            arr.push("</table>");
            $("#divList1").html(arr.join('')); // 显示列表
        }
        function ShowRoomNoList() {
            var bid = LexunJS.GetQueryString("id");  // 楼盘ID
            $("#divList1").html("<img src=\"../images/loading.gif\" />"); // 清空列表 
            $.ajax({
                type: 'POST',
                url: '../Handler/HandlerRoomNo.ashx',
                data: 'act=SelectRoomNoList&bid=' + bid,
                timeout: '10000',
                error: function() {
                    alert("系统繁忙,请稍候后试！");
                }, success: function(json) {
                    listCallBack(json);
                }
            });
         }
         function Search() {
            var floor = document.getElementById("txtFloor").value;
            if (LexunJS.Trim(floor) == "") {
                ShowRoomNoList();
            } else {
                SelectRoomNoList();
             }
         }
        function SelectRoomNoList() {
            var bid = LexunJS.GetQueryString("id");  // 楼盘ID
            var floor = document.getElementById("txtFloor").value;
            if (floor == "") {
                alert("请输入楼层");
                return;
             }
            $("#divList1").html("<img src=\"../images/loading.gif\" />"); // 清空列表 
            $.ajax({
                type: 'POST',
                url: '../Handler/HandlerRoomNo.ashx',
                data: 'act=SelectNameByFloor&bid=' + bid + '&floor=' + floor,
                timeout: '10000',
                error: function() {
                    alert("系统繁忙,请稍候后试！");
                }, success: function(json) {
                    listCallBack(json);
                }
            });
        }
        function RoomNolistCallBack(response) {
            var json = eval("(" + response + ")");
            var record = json.record;
            if (record == null || record.length == 0) {
                $("#divList1").html("<font color='red'>&nbsp;系统内暂无您查询的信息!</font>");
                return;
            }
            var arr = [];
            arr.push("<table id='table1' width='100%' border='0' cellpadding='0' cellspacing='1' bgcolor='#a8c7ce'>");
            arr.push("<tr>");
            arr.push("<td height='25' width='30px' bgcolor='d3eaef' class='STYLE6'>");
            arr.push("楼层");
            arr.push("</td>");
            arr.push("<td height='25' width='30px' bgcolor='d3eaef' class='STYLE6'>");
            arr.push("用途");
            arr.push("</td>");
            arr.push("<td height='25' bgcolor='d3eaef' class='STYLE6'>");
            arr.push("房号");
            arr.push("</td>");
            arr.push("</tr>");

            var recordLength = record.length;
            var floor1 = -9999;
            var floor2 = 0;
            for (var i = 0; i < recordLength; i++) {
                floor2 = record[i].floor;

                if (floor1 != floor2) {
                    if (floor1 != -9999) {
                        arr.push("</ul>");
                        arr.push("</td>");
                        arr.push("</tr>");
                    }
                    floor1 = floor2
                    if (i % 2 == 0)
                        arr.push("<tr id='tr_" + record[i].id + "' bgcolor='#FFFFFF'>");
                    else
                        arr.push("<tr id='tr_" + record[i].id + "' bgcolor='#EEEDED'>");

                    arr.push("<td height='20' class='STYLE6'>");
                    arr.push(floor2);
                    arr.push("</td>");
                    arr.push("<td height='20' class='STYLE6'>");
                    arr.push(record[i].usage);
                    arr.push("</td>");
                    arr.push("<td height='20' class='STYLE6'>");
                    arr.push("<ul>");
                }
                //                var showback = false;
                if (record[i].bstatus == 1) {
                    arr.push("<li  style = 'background:#FF99FF' >");
                }
                else if (record[i].bstatus == 2) {
                    arr.push("<li style = 'background:Yellow' >");
                }
                else if (record[i].bstatus == 3) {
                    arr.push("<li style = 'background:#66CCFF' >");
                }
                else {
                    //                    showback = true;
                    arr.push("<li>");
                }
                arr.push("<div title='" + record[i].name + "'>" + record[i].name + "</div>");

                alert("22"+record[i].isvalid);
                if (record[i].isvalid == 1)
                    arr.push("<div style='color:red;'>未审核</div>");
                else {

                    if (record[i].bstatus != 3) {
                        arr.push("<a  href=\"javascript:getVal('" + record[i].id + "','" + record[i].name + "','" + record[i].floor + "')\"  style='color:blue'  href='' >取回</a>");
                    }
              
                }
                arr.push("</li>");
            }
            arr.push("</table>");
            $("#divList1").html(arr.join('')); // 显示列表

         }
    </script>

</head>
<body>
    <form id="form1" runat="server">
  
    <div style="text-align: center;">
        <table width='100%' border='0' cellpadding='0' cellspacing='1' bgcolor='#CCCCCC'>
            <tr>
                <td bgcolor='F7F7F7'>
                    栋阁名称：<input id="txtEsate" name="txtEsate"    style="width:35%" runat="server" class="textstyle1" type="text" />&nbsp;&nbsp;楼层&nbsp;
                    <input id="txtFloor"
                        type="text"  class="text"/>&nbsp;
                    <input id="btnSearch" type="button" value="搜索" class="button_bak" style="cursor: pointer;" onclick="Search();"/>
                    <span>&nbsp;&nbsp; (点击取回！)</span>
                </td>
            </tr>
        </table>
        <asp:Literal ID="ltDiv" runat="server"></asp:Literal>
    </div> 
    <div id="divList1">
    </div>
    </form>
</body>
</html>
